package com.xinzhi.controller;
import com.xinzhi.anno.CheckRole;
import com.xinzhi.domain.Supplier;
import com.xinzhi.service.SupplierService;
import com.xinzhi.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@CrossOrigin
@Controller
@ResponseBody
@CheckRole(role = {"admin"})
@RequestMapping("/Supplier")
public class SupplierController {
    @Autowired
    SupplierService supplierService;

    @RequestMapping("/update")
    @ResponseBody
    public Result update(Supplier supplier) {
        //修改供应商信息
        return supplierService.updateSupplier(supplier);

    }
    @RequestMapping("/findAll")
    @ResponseBody
    public List<Supplier> findAll(){
        //查询全部供应商信息
        return supplierService.selectList();

    }

    @RequestMapping("/delete")
    @ResponseBody
    public Result delete(Supplier supplier){
        //删除供应商信息
        return supplierService.delete(supplier);
    }
    @RequestMapping("/insert")
    @ResponseBody
    public Result insert(Supplier supplier){
        //添加供应商信息
        return supplierService.insert(supplier);

    }
}
